package r21310.chap06.d1123;

import java.util.SortedSet;
import java.util.TreeSet;

public class Demo04TreeSet {
    public static void main(String[] args) {
        Stu stu1=new Stu("张三",80,"111");
        Stu stu2=new Stu("李四",90,"222");
        Stu stu3=new Stu("张飞",88,"333");
        Stu stu4=new Stu("刘备",76,"444");
        /*TreeSet<Stu> set=new TreeSet<>(new Comparator<Stu>() {
            @Override
            public int compare(Stu o1, Stu o2) {
                return Double.compare(o1.getChengji(), o2.getChengji());
            }
        });*/

        TreeSet<Stu> set=new TreeSet<>(( o1,  o2) ->Double.compare(Integer.valueOf(o1.getNum()),Integer.valueOf(o2.getNum() )));

        set.add(stu1);
        set.add(stu2);
        set.add(stu3);
        set.add(stu4);
       // System.out.println(set);
       // System.out.println(set.first());//要用这个方法需要在开始定义时都定义了

        SortedSet<Stu> seet=set.subSet(new Stu("aa",0,"111"),new Stu("aa",100,"444"));
        System.out.println(seet);
    }
}
